<?php

class activity {

    var $table;

    function activity() {
        $this->table = "activity";
    }

    function insert($data) {
        global $db;
        if (!is_null($data) && is_array($data)) {
            if ($db->exec_insert($this->table, $data))
                return $db->mysql_insert_id();
        }
        return false;
    }

    function getAll($limit=50) {
        global $db;
        $mid = $_SESSION['client']['id'];
       
        $result=array();
        if (intval($mid)) {
            
            $sql = "SELECT a.content,a.type,a.create_date,m.*,CONCAT(first_name,' ', last_name) as fullname FROM activity as a INNER JOIN member as m ON a.mid=m.id WHERE mid in (SELECT friend_id FROM friend WHERE mid={$mid}) or m.geo_id=".$_SESSION['client']["geo_id"]." ORDER BY a.id DESC limit 0,$limit";
            $rs = $db->query($sql);
            while ($row=$db->FetchToArray($rs))
            {
                $result[]=$row;
            }
          
            return $result;
        } else {
            return FALSE;
        }
    }

}

?>
